package com.zpark.component;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WorkProducer {

    @Autowired
    private AmqpTemplate amqpTemplate;

    public void send(int times) {
        for(int i=0; i<times; i++){
            String msg = "Hello! Work Queue";
            System.out.println("生产者：发送 msg -> " + msg);
            amqpTemplate.convertAndSend("my_work_queue", msg);
        }
    }

}
